package cn.tedu.tmall.admin.content.controller;

import cn.tedu.tmall.admin.content.service.ICategoryService;
import cn.tedu.tmall.common.pojo.po.CategoryPO;
import cn.tedu.tmall.common.web.JsonResult;
import com.github.xiaoymin.knife4j.annotations.ApiOperationSupport;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiImplicitParam;
import io.swagger.annotations.ApiOperation;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import java.util.List;

@Api(tags = "2.查询类别")
@RestController
@RequestMapping("/category")
public class CategoryController {
    @Autowired
    private ICategoryService service;
    @ApiOperation("根据父级id查询子级")
    @ApiOperationSupport(order = 100)
    @GetMapping("/list-by-parentId")
    @ApiImplicitParam(name = "parentId", value = "父级ID", dataType= "long", required = true)
    public JsonResult listByParentId(Long parentId){
        List<CategoryPO> categoryPOS = service.listByParentId(parentId);
        return JsonResult.ok(categoryPOS);
    }
}
